Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append Specific function to handle host in history #141

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

belotn
Copy link
Contributor

@belotn belotn commented Apr 2, 2022

fzf allow to complete ssh|telnet command with a list of known hosts. The purpose of this is to allow to grab all host (from command invoke-command or enter-pssesion ) from history and append it to prompt

PSFzf.Base.ps1 Outdated
@@ -836,6 +836,39 @@ function Invoke-FzfPsReadlineHandlerHistoryArgs {
}
}

function Invoke-FzfHandlerHistoryHost {
$Commands = @('icm','Invoke-Command','Enter-PSSession','etsn')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit limiting, and seems case-sensitive? Should probably be using (Get-Command $Name -Type Alias).ResolvedCommandname (plus error checking) to get the command from an alias so that it also works for custom aliases, not just icm and etsn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ! Maybe something like that :

	$Cmdlets = @('Invoke-Command','Enter-PSSession')
	$Alias = (get-alias |? { $Cmdlets -contains $_.ResolvedCommand }).Name
	$Commands = $Cmdlets + $Alias

And as in Powershell 5, Get-Service, Get-Process, Get-WmiObject used to have a "-ComputerName" parameters, this entries should be searched in history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants